//package com.old.controller;
//
//import com.old.result.Result;
//import com.old.service.VoskService;
//import lombok.RequiredArgsConstructor;
//import org.springframework.web.bind.annotation.CrossOrigin;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.multipart.MultipartFile;
//import org.vosk.LibVosk;
//import org.vosk.LogLevel;
//import org.vosk.Model;
//import org.vosk.Recognizer;
//
//import javax.sound.sampled.AudioInputStream;
//import javax.sound.sampled.AudioSystem;
//import java.io.File;
//import java.io.IOException;
//import java.nio.file.Files;
//import java.nio.file.Path;
//
//@RestController
//@RequiredArgsConstructor
//@CrossOrigin(origins = "*", allowedHeaders = "*")
//public class VoskController {
//
//    private final VoskService voskService;
//    @PostMapping("/recognize")
//    public Result recognize(@RequestParam MultipartFile file) throws Exception {
//        try {
//            Path tempFile = Files.createTempFile("audio_", ".wav");
//            file.transferTo(tempFile);
//
//            // 调用 Vosk 识别
//            String text = voskService.transcribe(tempFile.toString());
//            System.out.println("识别结果："+text);
//            return Result.success(text);
//        } catch (IOException e) {
//            return Result.error("上传失败");
//        }
//    }
//}
